package org.niux.aims.models;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Entitys entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "entitys", catalog = "aims")
public class Entitys implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = -7287102295939220091L;
	private Integer id;
	private EntityType entityType;
	private Entitys entitys;
	private Application application;
	private String entityName;
	private String entityCode;
	private Set<Auth> auths = new HashSet<Auth>(0);
	private Set<Entitys> entityses = new HashSet<Entitys>(0);

	// Constructors

	/** default constructor */
	public Entitys() {
	}

	/** minimal constructor */
	public Entitys(EntityType entityType, Application application,
			String entityName, String entityCode) {
		this.entityType = entityType;
		this.application = application;
		this.entityName = entityName;
		this.entityCode = entityCode;
	}

	/** full constructor */
	public Entitys(EntityType entityType, Entitys entitys,
			Application application, String entityName, String entityCode,
			Set<Auth> auths, Set<Entitys> entityses) {
		this.entityType = entityType;
		this.entitys = entitys;
		this.application = application;
		this.entityName = entityName;
		this.entityCode = entityCode;
		this.auths = auths;
		this.entityses = entityses;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY )
	@JoinColumn(name = "ENTITY_TYPE_ID", nullable = false)
	public EntityType getEntityType() {
		return this.entityType;
	}

	public void setEntityType(EntityType entityType) {
		this.entityType = entityType;
	}

	@ManyToOne(fetch = FetchType.LAZY )
	@JoinColumn(name = "PARENT_ID")
	public Entitys getEntitys() {
		return this.entitys;
	}

	public void setEntitys(Entitys entitys) {
		this.entitys = entitys;
	}

	@ManyToOne(fetch = FetchType.LAZY )
	@JoinColumn(name = "APPLICATION_ID", nullable = false)
	public Application getApplication() {
		return this.application;
	}

	public void setApplication(Application application) {
		this.application = application;
	}

	@Column(name = "ENTITY_NAME", nullable = false, length = 100)
	public String getEntityName() {
		return this.entityName;
	}

	public void setEntityName(String entityName) {
		this.entityName = entityName;
	}

	@Column(name = "ENTITY_CODE", nullable = false, length = 50)
	public String getEntityCode() {
		return this.entityCode;
	}

	public void setEntityCode(String entityCode) {
		this.entityCode = entityCode;
	}

	@OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY , mappedBy = "entitys")
	@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
	public Set<Auth> getAuths() {
		return this.auths;
	}

	public void setAuths(Set<Auth> auths) {
		this.auths = auths;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY , mappedBy = "entitys")
	@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
	public Set<Entitys> getEntityses() {
		return this.entityses;
	}

	public void setEntityses(Set<Entitys> entityses) {
		this.entityses = entityses;
	}

}